package flatlandRPGTest;

import flatlandRPG.Player;
import org.lwjgl.util.vector.Vector2f;
import flatlandRPG.GLPrimitive;
import flatlandRPG.Building;

// -------------------------------------------------------------------------
/**
 * Tests the Building class and it's collision with the player.
 *
 * @author evant
 * @version Apr 17, 2011
 */
public class BuildingTest
    extends GLPolygonTest
{
    private Building testBuilding;
    private Player   testPlayer;


    public void setUp()
    {
        super.setUp();
        testBuilding = (Building)getPrimitive();
        testPlayer = new Player();
    }


    @Override
    public GLPrimitive getPrimitive()
    {
        return new Building(
            new Vector2f(0, 0),
            new Vector2f(0, 1),
            new Vector2f(1, 1));
    }


    // ----------------------------------------------------------
    /**
     * Tests that collidedWith() should return false when there is no collision.
     */
    public void testNotCollidedWith()
    {
        testPlayer.setLocation(new Vector2f(-1, -1));

        assertFalse(testBuilding.collidedWith(testPlayer));
    }


    // ----------------------------------------------------------
    /**
     * Tests that collidedWith() should return true when there is a collision.
     */
    public void testCollidedWith()
    {
        assertTrue(testBuilding.collidedWith(testPlayer));
    }
}
